import os
import json
from common.path_util import get_file_path,files

'''
script 解析sql语句
'''
read_path=r'C:\Users\me\Desktop\scripts\scripts'
write_path=r'C:\Users\me\Desktop\sql'

get_file_path(read_path)
file_list=files
for file in file_list:
    file_name=file.split('\\')[-1].split('.script')[0]
    out_file_path=write_path+'\\'+file_name+'.sql'
    sqls=str()
    print(file)
    with open(file=file,mode='r',encoding='utf-8') as rf:
          lines=rf.readlines()
          sqls=json.loads(''.join(lines))['content']
          print(sqls)
    with open(file=out_file_path,mode='w',encoding='utf-8') as rw:
          rw.write(sqls)

